Answer:

Probably not. Even with a hand calculator this would be tedious.

Adding Up Integers

There is a formula for the sum of integers from 0 to N, and similar formulas for the sum of even or of odd integers from 0 to N, (look in your calculus book if you are interested). But pretend that you don't know that. Let us write a program that calculates these three sums by directly adding up the integers. The user enters N, and the program counts up from zero to N, adding each integer to the appropriate sum.

Here is a flowchart that shows how the program works. The flowchart shows the logic, but not the details of Java syntax.

flowchart of program

Pick some small integer, perhaps N==3, and follow the flowchart by hand to see how it works. Then try some unexpected values, like N==0 or N==1 that the logic might not take care of.

QUESTION 2:

Does the flowchart work for N==0?